<?php include("includes/connect_db.php"); ?>

<style>
	.table{
		border: 1px solid #DDD;
	}
	.tr-header{
		background-color: #0088cc; 
		color: #FFF;
	}
	.tr-super{
		background-color: #666;
		color: #FFF;
	}
</style>

<?php
	$id_host = $_POST['id'];
	$nama_tabel = $_POST['namaTabel'];

	$sql_lihat_host = "SELECT * FROM tb_host WHERE id_host = '$id_host'";
	$query_lihat_host = mysql_query($sql_lihat_host);
	$lihat_host = mysql_fetch_array($query_lihat_host);

	$koneksiBaru = mysql_connect($lihat_host['host'], $lihat_host['username'], $lihat_host['password']) or die("Connection Error: " . mysql_error());

	mysql_select_db($lihat_host['db'], $koneksiBaru) or die("Error conecting to db.");
?>

	<table class="table table-bordered" style="width: 100%">
		<tr class="tr-super">
			<td colspan="3"><?php echo $nama_tabel; ?></td>
		</tr>
		<tr class="tr-header">
			<td style="width: 35%">Nama Kolom</td>
			<td style="width: 55%">Tipe Data</td>
			<td style="width: 10%; text-align: center">Key</td>
		</tr>
<?php
	$sql_lihat_info = "DESC $nama_tabel";
	$query_lihat_info = mysql_query($sql_lihat_info, $koneksiBaru);
	while ($lihat_info = mysql_fetch_array($query_lihat_info)) {
?>
	
		<tr>
			<td><?php echo $lihat_info[0]; ?></td>
			<td><?php echo $lihat_info[1]; ?></td>
			<td style="text-align: center">
				<?php 
					if ($lihat_info[3] != '') {
						echo "<i class='icon-check'></i>";
					}
				?>
			</td>
		</tr>

<?php
	}
?>	
	</table>
